package lesson02.UDP;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UDPDictServer01 extends UDPEchoServer01 {
    private Map<String, String> map;

    public UDPDictServer01(int port) throws SocketException {
        super(port);
        map = new HashMap<>();
        map.put("tiger", "老虎");
        map.put("cat", "猫");
        map.put("dog", "狗");
        map.put("pig", "猪");
    }
    protected String process(String key){
        String response= map.getOrDefault(key,"查无此人");
        return response;
    }

    public static void main(String[] args) throws IOException {
        UDPDictServer01 server = new UDPDictServer01(9999);
        server.start();
    }

}
